﻿//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
//  PURPOSE.
//
//  License: GNU Lesser General Public License (LGPLv3)
//
//  Email: alaabenfatma@yahoo.fr
//
//  Copyright (C) Alaa Ben Fatma, 2016-2017. 

namespace CharmNotification
{
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    using CharmNotification.Properties;

    public partial class Notification : Component
    {
        public Notification()
        {
            InitializeComponent();
        }

        public Notification(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }
        [Description("The color of the left side of the notification."), Category("Appearance"),
         DefaultValue(typeof(bool), null), Browsable(true)]
        public bool PlayTone { get; set; } = true;

        [Description("The color of the left side of the notification."), Category("Appearance"), 
         DefaultValue(typeof(ColorDialog), null), Browsable(true)]
        public Color BackColor1 { get; set; } = Color.FromArgb(150, 150, 150);

        [Description("The color of the right side of the notification."), Category("Appearance"), 
         DefaultValue(typeof(ColorDialog), null), Browsable(true)]
        public Color BackColor2 { get; set; } = Color.FromArgb(204, 204, 204);

        [Description("Duration of the notification."), Category("Appearance"), DefaultValue(typeof(NumericUpDown), null), 
         Browsable(true)]
        public int Duration { get; set; } = 3000;

        [Description("The icon of the notification."), Category("Appearance"), DefaultValue(typeof(PictureBox), null), 
         Browsable(true)]
        public Image Icon { get; set; } = Resources._43_Bell_32;

        [Description("The text of the notification"), Category("Appearance"), DefaultValue(typeof(TextBox), null), 
         Browsable(true)]
        public string Text { get; set; }

        [Description("The color of the text."), Category("Appearance"), DefaultValue(typeof(ColorDialog), null), 
         Browsable(true)]
        public Color TextForeColor { get; set; } = Color.Black;

        [Description("The title of the notification"), Category("Appearance"), DefaultValue(typeof(TextBox), null), 
         Browsable(true)]
        public string Title { get; set; }

        [Description("The color of the title."), Category("Appearance"), DefaultValue(typeof(ColorDialog), null), 
         Browsable(true)]
        public Color TitleForeColor { get; set; } = Color.Black;

        public void ShowNotification()
        {
            this.ShowNotification(
                this.Duration,
                this.PlayTone,
                this.Title, 
                this.Text, 
                this.BackColor1, 
                this.BackColor2, 
                this.TitleForeColor, 
                this.TextForeColor);
        }

        private void ShowNotification(
            int Duration, bool Play,
            string Title, 
            string Text, 
            Color Color1, 
            Color Color2, 
            Color TitleColor, 
            Color TextColor)
        {
            var NH = new NotificationHost(Duration,Play, Title, Text, this.Icon, Color1, Color2, TitleColor, TextColor);
            NH.Show();
        }
    }
}